package com.ck.company.service;

import com.ck.exception.ServiceException;
import com.ck.model.common.Picture;
import com.ck.model.common.page.PageInfo;
import com.ck.model.company.vo.CpPictureListVO;
import com.ck.model.company.vo.CpProgramPictureListVO;
import com.github.pagehelper.Page;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Map;

/**
 * 图片Service
 *
 * @author dxy
 * @date 2018/7/4 9:54
 */
public interface CpPictureService {

	/**
	 * 保存图片
	 *
	 * @param pictureFile MultipartFile
	 * @param request     HttpServletRequest
	 * @return Map<String                                                               ,                                                               Object>
	 */
	Map<String, Object> savePicture(MultipartFile pictureFile, HttpServletRequest request) throws IOException, ServiceException;

	/**
	 * 重命名
	 *
	 * @param pictureId      图片ID
	 * @param picutreNewName 图片新名称
	 * @param request        HttpServletRequest
	 * @throws ServiceException
	 * @throws IOException
	 */
	void renamePicture(Long pictureId, String picutreNewName, HttpServletRequest request) throws ServiceException, IOException;

	/**
	 * 图片列表
	 *
	 * @param companyCode 商家编码
	 * @param pictureName 图片名称
	 * @param pageNum     当前页
	 * @param pageSize    每页显示条数
	 * @return List<CpPictureListVO>
	 */
	PageInfo<CpPictureListVO> listPicture(String companyCode, String pictureName, Integer pageNum, Integer pageSize);

	/**
	 * 通过图片ID删除图片
	 *
	 * @param pictureId 图片ID
	 * @param request   HttpServletRequest
	 * @throws ServiceException
	 * @throws IOException
	 */
	void deletePictureById(Long pictureId, HttpServletRequest request) throws ServiceException, IOException;

	/**
	 * 通过图片组ID获取图片数量
	 *
	 * @param pictureGroupId 图片组ID
	 * @param companyCode    商家编码
	 * @return Long(图片数量)
	 */
	Long countPictureByPictureGroupId(Long pictureGroupId, String companyCode);

	/**
	 * 更新图片分组ID
	 *
	 * @param pictureGroupId 图片分组ID
	 * @param pictureId      图片ID
	 */
	public void updatePictureGroupId(Long pictureGroupId, Long pictureId) throws ServiceException;

	/**
	 * 节目选择图片列表
	 *
	 * @param companyCode    公司代码
	 * @param pictureGroupId 图片组ID
	 * @param pageNum        当前页
	 * @param pageSize       每页条数
	 * @return
	 */
	Page<CpProgramPictureListVO> listProgramPicture(String companyCode,Long pictureGroupId, Integer pageNum, Integer pageSize);

	/**
	 * 通过图片名称获取图片
	 *
	 * @param companyCode 商家编码
	 * @param pictureName 图片名称
	 * @return Picture
	 */
	Picture getPictureByName(String companyCode, String pictureName) throws ServiceException;

	/**
	 * 获取图片名称类似的条数
	 *
	 * @param companyCode 商家编码
	 * @param pictureName 图片名称
	 * @return Long(图片条数)
	 * @throws ServiceException
	 */
	Long countPictureByName(String companyCode, String pictureName) throws ServiceException;

    /**
     * 图片列表
     *
     * @param companyCode    商家编码
     * @param pictureName    图片名称
     * @param pictureGroupId 图片分组ID
     * @param pageNum        当前页
     * @param pageSize       每页显示条数
     * @return List<CpPictureListVO>
     */
    PageInfo<CpPictureListVO> list(String companyCode, String pictureName, Long pictureGroupId, Integer pageNum, Integer pageSize);

	/**
	 * 根据公司统计图片
	 * @param companyCode 商家编码
	 * @param hasGroup true无分组，false属于某个分组
     * @return long
	 */
	long countPictureByCompany(String companyCode, boolean hasGroup);

	/**
	 * 保存图片
	 *
	 * @param pictureFile MultipartFile
	 * @param request     HttpServletRequest
	 * @return Map<String                                                               ,                                                               Object>
	 */
	Map<String, Object> uploadForSceneBackground(MultipartFile pictureFile, HttpServletRequest request) throws IOException;
}
